/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1/commercial
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may use this file in compliance with the License.
 * Alternatively, if you can't copy with the License, namely if you do not
 * want to provide source code of your modifications to this file, you may
 * negotiate a commercial licence with the initial developer.
 * You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is COID.
 *
 * The Initial Developer of the Original Code is
 * PosAm.
 * Portions created by the Initial Developer are Copyright (C) 2003
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 * Brano Kemen
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

#include "server.h"

#include "coid/comm/binstream/cachestream.h"
#include "coid/comm/binstream/filestream.h"
#include "coid/comm/binstream/httpstreamtunnel.h"

#include "coid/comm/alloc/allocrp.h"

namespace coid {

/*

////////////////////////////////////////////////////////////////////////////////
struct test
{
    struct head
    {
        char k[256-4*4];
    };

    struct tail
    {
        int i;
    };

    enum { SEGSIZE = 8192 };

    fileiostream _fio;
    restricted_page_allocator<uint> _k;


    static opcd stream_out( const segarray<head,tail>::PERSIST& p )
    {
        fileiostream& fio = *(fileiostream*)p.context;
        int64 off = p.segsize*(int64)p.fileblock;
        fio.seek( binstream::fSEEK_WRITE, off );
        return fio.write_raw( p.segdata, p.segsize );
    }

    static opcd stream_in( const segarray<head,tail>::PERSIST& p )
    {
        fileiostream& fio = *(fileiostream*)p.context;
        int64 off = p.segsize*(int64)p.fileblock;
        fio.seek( binstream::fSEEK_READ, off );
        return fio.read_raw( p.segdata, p.segsize );
    }


    test()
    {
        segarray<head,tail> _sar;
        _sar.set_tail_element_count(4);
        _sar.set_segsize(SEGSIZE);

        _sar.set_fnc_stream( &_fio, stream_out, stream_in );
        _sar.set_max_memory( 2*SEGSIZE );

        _fio.open( "segarray.swap?rwct" );


        typedef segarray<head,tail>::ptr sptr;
        {
            sptr x;

            _sar.ins(0,x,1);
            x.del(1);

            _sar.ins(0,x,10);
            _sar.ins(0,x,100);

            _sar.get_ptr( 33, x );
        }

        _sar.ins( _sar.size(), 100 );
        _sar.ins( _sar.size(), 100 );

        {
            sptr x;  
            _sar.get_ptr( 0, x );
        }

        {
            sptr x;  
            _sar.get_ptr( 200, x );
        }

        _sar.ins( _sar.size(), 100 );
        _sar.ins( _sar.size(), 100 );

        {
            sptr x;  
            _sar.get_ptr( 200, x );
        }

        _sar.ins( _sar.size(), 100 );

        {
            sptr x;  
            _sar.get_ptr( 0, x );
        }


        //uint* p = _k.alloc(10,0);
        //_k.reserve( p, 300, true, 0 );
        //_k.realloc(p,20,1,0);
        //_k.free(p);
    }
};

static test G;
*/
} // namespace coid
